package com.ece.gui;

import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import com.ece.control.ItemController;

public class CategoryPanel extends JPanel{
	private final JList itemCategoryList = new JList();

	public CategoryPanel() {
		this.setSize(200, 200);

		itemCategoryList.setFixedCellHeight(20);
		itemCategoryList.setFixedCellWidth(195);
		itemCategoryList.setVisibleRowCount(10);
		DefaultListModel listModel = new DefaultListModel();
		listModel.addElement("Livres");
		listModel.addElement("DVD");
		itemCategoryList.setModel(listModel);
		itemCategoryList.addListSelectionListener(new ListSelectionListener() {
			@Override
			public void valueChanged(ListSelectionEvent arg0) {
				ItemController.setItemList((String)itemCategoryList.getSelectedValue());
			}
		});

		this.add(itemCategoryList);
	}
}
